# -*- coding: utf-8 -*-
from __future__ import unicode_literals
"""
demo11_eig.py 特征值与特征向量
"""
import numpy as np

A = np.mat('3 4 6; 2 3 -1; 5 7 11')
print(A)
# 提取特征值
eigvals, eigvecs = np.linalg.eig(A)
print(eigvals)
print(eigvecs)

# 求原方阵
eigvals[2:] = 0  # 抹掉部分特征值
A2 = eigvecs * np.diag(eigvals) * eigvecs.I
print(A2)
